package neuroPoker.visualisation;

import java.awt.Rectangle;

import javax.swing.JComponent;

import neuroPoker.netze.NetKarte;

public class KarteComp extends JComponent {

	private static final long serialVersionUID = 4434521642757706857L;

	public NetKarte karte;

	public KarteComp(NetKarte k) {
		this.setLayout(null);
		karte = k;
		String cardfile = getCardFile(karte);
		ImageComponent ic = new ImageComponent(cardfile, 50, 67);
		this.add(ic);
		ic.setLocation(0, 0);
		this.setBounds(new Rectangle(50, 67));
	}

	public KarteComp(String cardfile, NetKarte k) {
		karte = k;
		this.setLayout(null);
		ImageComponent ic = new ImageComponent("/Images/kartenset/" + cardfile,
				50, 67);
		this.add(ic);
		ic.setLocation(0, 0);
		this.setBounds(new Rectangle(50, 67));
	}

	public void setKarte(NetKarte k) {
		this.removeAll();
		this.setLayout(null);
		karte = k;
		String cardfile = getCardFile(karte);
		ImageComponent ic = new ImageComponent(cardfile, 50, 67);
		this.add(ic);
		ic.setLocation(0, 0);
		this.repaint();
	}

	public String getCardFile(NetKarte karte) {
		return "/Images/kartenset/" + karte.toString() + ".bmp";
	}
}
